|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neo4j.helpers.collection.IteratorUtil
public abstract class IteratorUtil
Contains common functionality regarding Iterators.
| Constructor Summary | |
|---|---|
IteratorUtil()
|
|
| Method Summary | ||
|---|---|---|
static
|
addToCollection(Iterator<T> iterator,
C collection)
Adds all the items in iterator to collection. |
|
static
|
asIterable(Iterator<T> iterator)
Exposes iterator as an Iterable. |
|
static
|
count(Iterator<T> iterator)
Counts the number of items in the iterator by looping
through it. |
|
static
|
singleValueOrNull(Iterator<T> iterator)
Returns the given iterator's only value or null if there was no
items in the iterator. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IteratorUtil()
| Method Detail |
|---|
public static <T> T singleValueOrNull(Iterator<T> iterator)
null if there was no
items in the iterator. If there is more than one value in the iterator
an IllegalArgumentException will be thrown.
T - the type of items in iterator.iterator - the Iterator to get items from.
iterator, or null if no
value was found. Throws IllegalArgumentException if more than
one value was found.
public static <C extends Collection<T>,T> C addToCollection(Iterator<T> iterator,
C collection)
iterator to collection.
C - the type of Collection to add to items to.T - the type of items in the collection and iterator.iterator - the Iterator to grab the items from.collection - the Collection to add the items to.
collection which was passed in, now filled
with the items from iterator.public static <T> Iterable<T> asIterable(Iterator<T> iterator)
iterator as an Iterable. It breaks the contract
of Iterable in that it returns the supplied iterator instance
for each call to iterable() on the returned Iterable
instance. This method mostly exists to make it easy to use an
Iterator in a for-loop.
T - the type of items in the iterator.iterator - the iterator to expose as an Iterable.
Iterable.public static <T> int count(Iterator<T> iterator)
iterator by looping
through it.
T - the type of items in the iterator.iterator - the Iterator to count items in.
iterator.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||